/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.agent.controller;

import cn.ac.iie.agent.execute.AgentDataCollectHandler;
import cn.ac.iie.agent.execute.KillMyself;
import cn.ac.iie.agent.tools.PropsFiles;
import cn.ac.iie.di.commons.httpserver.framework.server.HttpServer;

/**
 *
 * @author zhangyun
 */
public class AgentServer {

    public void run() throws Exception {
        PropsFiles ps = new PropsFiles();
        HttpServer httpServer = HttpServer.getHttpServer(ps.getValue("jettyServerIP"), Integer.parseInt(ps.getValue("jettyServerPort")), 32);
        httpServer.registerContext("/agent");
        httpServer.registerContextHandler("/agent", "/collector", AgentDataCollectHandler.class);
        httpServer.registerContext("/agent");
        httpServer.registerContextHandler("/agent", "/kill", AgentDataCollectHandler.class);
        httpServer.registerContext("/agent");
        httpServer.registerContextHandler("/agent", "/killmyself", KillMyself.class);
        httpServer.startup();
    }
}
